﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

namespace ZGameFramework.UI
{
    public class BubbleCellAlpha : BubbelCellBase
    {

        [HideInInspector] public float from = 0;
        [HideInInspector] public float to = 1;

        private CanvasGroup canvasGroup;
        private MaskableGraphic maskableGraphic; 
       

        private void OnEnable()
        {
            canvasGroup = this.GetComponent<CanvasGroup>();
            maskableGraphic = this.GetComponent<MaskableGraphic>();

            if (null != canvasGroup) { canvasGroup.alpha = from; }
           
        }

        public override void StartFadeIn()
        {
            base.StartFadeIn();
            if ( null != canvasGroup) { canvasGroup.alpha = from; canvasGroup.DOFade(to, duration); }
        }

        public override void StartFadeOut()
        {
            base.StartFadeOut();

            if (null != canvasGroup) { canvasGroup.alpha = to; canvasGroup.DOFade(from, duration); }
        }
    }

}